<?php

/**
 * 获取护理统计数据
 * @authors Hex (hex@zpdchina.com)
 * @date    2017-03-09 11:09:02
 * @version $Id$
 */
class GethulitongjiDataController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        $request = $this->getRequest();
        $yiyuan_id = $request->getPost('yiyuan_id',0);
        $start_date = $request->getPost('kaishi_time','');
        $end_date = $request->getPost('jieshu_time','');
        $user_number = $request->getPost('user_number','');
//        if(empty($yiyuan_id))
//            Utility::apiJsonError(30001, '医院编号不能为空');
        if(empty($user_number))
            Utility::apiJsonError(30021, '用户账号不能为空');
        if(empty($start_date))
            $start_date = date("Y-m-d");
        if(empty($end_date))
            $end_date = date("Y-m-d");
        $start_date_time = $start_date." 00:00";
        $end_date_time = $end_date." 23:59";
        $hltj_mdl = new ZhuyuanHuliTongjiModel;
        //获取护理统计配置数据
        $data_tongji_item_list = $hltj_mdl->getTongjiItemList();
        $tongji_list = array();
        foreach($data_tongji_item_list as $key => $data_tongji_item)
        {
            $tongji_list[$key]["item_id"] = $data_tongji_item["id"];
            $tongji_list[$key]["item_name"] = $data_tongji_item["tongji_item_name"];
            //统计条数
            $tongji_list[$key]["cishu"] = $hltj_mdl->getTongjiCishu($user_number,$start_date_time,$end_date_time,$data_tongji_item["tongji_item_code"]);
            $tongji_list[$key]['sub_list'] = $hltj_mdl->getTongjiSubList($user_number,$start_date_time,$end_date_time,$data_tongji_item["tongji_item_code"]);
        }
        $result["state"] = empty($tongji_list)?'0':'1';
        $result["result"] = $tongji_list;
        $result["error"] = 200;
        $result["msg"] = "";
        Utility::apiJsonResultExtends($result);
    }

}